package com.badger.pattern.factory;

/**
 * 简单工厂
 * @author liqi
 *
 */
public class TestFactory {
    public static void main(String[] args) {
        IceCreamFactory factory = new IceCreamFactory();
        IceCream ice = factory.buildIceCream(1);
        System.out.println(ice.getName() + "----" + ice.getFlavor());
    }
}

/**
 * 简单工厂
 * @author liqi
 *
 */
class IceCreamFactory {
    public IceCream buildIceCream(int i) {
        IceCream ice;
        switch (i) {
        case 1:
            ice = new SuiBianIceCream("随变冰淇淋", "甜的");
            break;
        default:
            ice = new OldIceCream("老冰棍", "咸的");
            break;
        }
        return ice;
    }
}
